// 全局测试配置
import '@testing-library/jest-dom';
import 'jest-canvas-mock';

// 模拟 window.URL.createObjectURL
if (typeof global !== 'undefined' && global.URL) {
  global.URL.createObjectURL = jest.fn(() => 'mock-url');
}

// 模拟 ResizeObserver
if (typeof global !== 'undefined') {
  global.ResizeObserver = class ResizeObserver {
    observe() {}
    unobserve() {}
    disconnect() {}
  };
}

// 模拟 matchMedia
Object.defineProperty(window, 'matchMedia', {
  writable: true,
  value: (query: string) => ({
    matches: false,
    media: query,
    onchange: null,
    addListener: () => {},
    removeListener: () => {},
    addEventListener: () => {},
    removeEventListener: () => {},
    dispatchEvent: () => false,
  }),
});

// 模拟 requestAnimationFrame
if (typeof global !== 'undefined') {
  global.requestAnimationFrame = (callback: FrameRequestCallback) => {
    setTimeout(callback, 0);
    return 0;
  };
  
  global.cancelAnimationFrame = () => {};
}
